﻿$(document).ready(function () {
    // Set up a listener so that when anything with a class of 'tab'
    // is clicked, this function is run.
    // Switching between tabs can be disabled/enabled based on the status (of busy class or not)
    $('.tab').click(function () {
        // disable clicking while page is still busy validating
        if ($('#tabs_container').is('#tabs_container.busy'))
            return;

        // Remove the 'active' class from the active tab.
        $('#tabs_container li.active').removeClass('active');

        // Add the 'active' class to the clicked tab.
        $(this).parent().addClass('active');

        // Remove the 'tab_contents_active' class from the visible tab contents.
        $('.tab_contents_container div.tab_contents_active').removeClass('tab_contents_active');

        // Add the 'tab_contents_active' class to the associated tab contents.
        $(this.rel).addClass('tab_contents_active');

        // clear the result and resource areas
        Reset();
    });

});

function disableTabSwitch() {
    $('#tabs_container').addClass('busy');
    $("#liveValidateButton").attr("disabled", true);
    $("#offlineValidateButton").attr("disabled", true);
};

function enableTabSwitch() {
    $('#tabs_container').removeClass('busy');
    $("#liveValidateButton").attr("disabled", false);
    $("#offlineValidateButton").attr("disabled", false);
};
